home *** CD-ROM | disk | FTP | other *** search
- /* file: radar.c
- sweeping line algorithm
- By MGD
- */
-
- #include "busybox.h"
- #include <math.h>
- #define abs(x) ((x <= 0) ? (-x) : (x))
- #define numSpots 48
-
- static Rect ourRect;
- static int16 numThru;
- static width, height;
-
- static Point circle[numSpots];
- static int16 radius;
- static int16 lasti;
- static Point centre;
-
-
- void InitRadarObj(Rect *drawArea, int16 ID) {
- /* You can put various stuffages here - i.e. load string resources, init a brick
- picture, oop ack. */
- int16 i;
- double sinner, cosinner, thetaStep, theta;
-
- ourRect = *drawArea;
- width = ourRect.right;
- height = ourRect.bottom;
-
- radius = width / 2;
- centre.h = radius;
- centre.v = radius;
- /* SetRect(&ourRect,0, 0, 500, 500); */
-
- thetaStep = (2*3.14159) / numSpots;
- theta = 0;
- for (i = 0; i < numSpots; i++) {
- circle[i].h = radius * cos(theta) + radius;
- circle[i].v = radius * sin(theta) + radius;
- theta += thetaStep;
- }
- lasti = 0;
- } /* InitRadarObj */
-
-
-
- void DrawRadarObj(int16 ID) {
-
- FillOval(&ourRect,black);
- MoveTo(centre.h, centre.v);
- PenPat(white);
- LineTo(circle[lasti].h, circle[lasti].v);
- lasti = (++lasti % numSpots);
- PenPat(black);
- } /* DrawRadarObj */
-
-
-
-